import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDMathx {
	/**ID*/
	id,
	/**物理攻击*/
	phyAtk,
	/**火焰攻击*/
	fireAtk,
	/**冰冻攻击*/
	iceAtk,
	/**闪电攻击*/
	lightAtk,
	/**物理抗性*/
	phyDef,
	/**火焰抗性*/
	fireDef,
	/**冰冻抗性*/
	iceDef,
	/**闪电抗性*/
	lightDef,
	/**生命*/
	hp,
	/**魔法*/
	mana,
	/**普攻急速*/
	normalQuick,
	/**急速*/
	quick,
	/**精准*/
	hit,
	/**连击*/
	dribble,
	/**闪避*/
	dodge,
	/**暴击*/
	crit,
	/**韧性*/
	res,
	/**格挡*/
	block,
	/**暴击伤害*/
	critDmg,
	/**生命恢复*/
	hpRegen,
	/**魔法恢复*/
	manaRegen,
	/**连击恢复*/
	dribbleRegen,
	/**闪避恢复*/
	dodgeRegen,
	/**暴击恢复*/
	critRegen,
	/**格挡恢复*/
	blockRegen,
	/**物理攻击百分比加成*/
	phyAtkPercent,
	/**火焰攻击百分比加成*/
	fireAtkPercent,
	/**冰冻攻击百分比加成*/
	iceAtkPercent,
	/**闪电攻击百分比加成*/
	lightAtkPercent,
	/**生命百分比加成*/
	hpPercent,
	/**魔法值百分比加成*/
	manaPercent,
	/**生命恢复加成*/
	hpRegenPercent,
	/**魔法恢复加成*/
	manaRegenPercent,
	/**连击恢复加成*/
	dribbleRegenPercent,
	/**闪避恢复加成*/
	dodgeRegenPercent,
	/**暴击恢复加成*/
	critRegenPercent,
	/**格挡恢复加成*/
	blockRegenPercent,

	/**枚举数量*/
	EnumCount
}



export class CDMathx{
	/**ID*/
	public id: number;
	/**物理攻击*/
	public phyAtk: number;
	/**火焰攻击*/
	public fireAtk: number;
	/**冰冻攻击*/
	public iceAtk: number;
	/**闪电攻击*/
	public lightAtk: number;
	/**物理抗性*/
	public phyDef: number;
	/**火焰抗性*/
	public fireDef: number;
	/**冰冻抗性*/
	public iceDef: number;
	/**闪电抗性*/
	public lightDef: number;
	/**生命*/
	public hp: number;
	/**魔法*/
	public mana: number;
	/**普攻急速*/
	public normalQuick: number;
	/**急速*/
	public quick: number;
	/**精准*/
	public hit: number;
	/**连击*/
	public dribble: number;
	/**闪避*/
	public dodge: number;
	/**暴击*/
	public crit: number;
	/**韧性*/
	public res: number;
	/**格挡*/
	public block: number;
	/**暴击伤害*/
	public critDmg: number;
	/**生命恢复*/
	public hpRegen: number;
	/**魔法恢复*/
	public manaRegen: number;
	/**连击恢复*/
	public dribbleRegen: number;
	/**闪避恢复*/
	public dodgeRegen: number;
	/**暴击恢复*/
	public critRegen: number;
	/**格挡恢复*/
	public blockRegen: number;
	/**物理攻击百分比加成*/
	public phyAtkPercent: number;
	/**火焰攻击百分比加成*/
	public fireAtkPercent: number;
	/**冰冻攻击百分比加成*/
	public iceAtkPercent: number;
	/**闪电攻击百分比加成*/
	public lightAtkPercent: number;
	/**生命百分比加成*/
	public hpPercent: number;
	/**魔法值百分比加成*/
	public manaPercent: number;
	/**生命恢复加成*/
	public hpRegenPercent: number;
	/**魔法恢复加成*/
	public manaRegenPercent: number;
	/**连击恢复加成*/
	public dribbleRegenPercent: number;
	/**闪避恢复加成*/
	public dodgeRegenPercent: number;
	/**暴击恢复加成*/
	public critRegenPercent: number;
	/**格挡恢复加成*/
	public blockRegenPercent: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDMathx.id: return this.id;
			case E_CDMathx.phyAtk: return this.phyAtk;
			case E_CDMathx.fireAtk: return this.fireAtk;
			case E_CDMathx.iceAtk: return this.iceAtk;
			case E_CDMathx.lightAtk: return this.lightAtk;
			case E_CDMathx.phyDef: return this.phyDef;
			case E_CDMathx.fireDef: return this.fireDef;
			case E_CDMathx.iceDef: return this.iceDef;
			case E_CDMathx.lightDef: return this.lightDef;
			case E_CDMathx.hp: return this.hp;
			case E_CDMathx.mana: return this.mana;
			case E_CDMathx.normalQuick: return this.normalQuick;
			case E_CDMathx.quick: return this.quick;
			case E_CDMathx.hit: return this.hit;
			case E_CDMathx.dribble: return this.dribble;
			case E_CDMathx.dodge: return this.dodge;
			case E_CDMathx.crit: return this.crit;
			case E_CDMathx.res: return this.res;
			case E_CDMathx.block: return this.block;
			case E_CDMathx.critDmg: return this.critDmg;
			case E_CDMathx.hpRegen: return this.hpRegen;
			case E_CDMathx.manaRegen: return this.manaRegen;
			case E_CDMathx.dribbleRegen: return this.dribbleRegen;
			case E_CDMathx.dodgeRegen: return this.dodgeRegen;
			case E_CDMathx.critRegen: return this.critRegen;
			case E_CDMathx.blockRegen: return this.blockRegen;
			case E_CDMathx.phyAtkPercent: return this.phyAtkPercent;
			case E_CDMathx.fireAtkPercent: return this.fireAtkPercent;
			case E_CDMathx.iceAtkPercent: return this.iceAtkPercent;
			case E_CDMathx.lightAtkPercent: return this.lightAtkPercent;
			case E_CDMathx.hpPercent: return this.hpPercent;
			case E_CDMathx.manaPercent: return this.manaPercent;
			case E_CDMathx.hpRegenPercent: return this.hpRegenPercent;
			case E_CDMathx.manaRegenPercent: return this.manaRegenPercent;
			case E_CDMathx.dribbleRegenPercent: return this.dribbleRegenPercent;
			case E_CDMathx.dodgeRegenPercent: return this.dodgeRegenPercent;
			case E_CDMathx.critRegenPercent: return this.critRegenPercent;
			case E_CDMathx.blockRegenPercent: return this.blockRegenPercent;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDMathx.id: this.id = v; break;
			case E_CDMathx.phyAtk: this.phyAtk = v; break;
			case E_CDMathx.fireAtk: this.fireAtk = v; break;
			case E_CDMathx.iceAtk: this.iceAtk = v; break;
			case E_CDMathx.lightAtk: this.lightAtk = v; break;
			case E_CDMathx.phyDef: this.phyDef = v; break;
			case E_CDMathx.fireDef: this.fireDef = v; break;
			case E_CDMathx.iceDef: this.iceDef = v; break;
			case E_CDMathx.lightDef: this.lightDef = v; break;
			case E_CDMathx.hp: this.hp = v; break;
			case E_CDMathx.mana: this.mana = v; break;
			case E_CDMathx.normalQuick: this.normalQuick = v; break;
			case E_CDMathx.quick: this.quick = v; break;
			case E_CDMathx.hit: this.hit = v; break;
			case E_CDMathx.dribble: this.dribble = v; break;
			case E_CDMathx.dodge: this.dodge = v; break;
			case E_CDMathx.crit: this.crit = v; break;
			case E_CDMathx.res: this.res = v; break;
			case E_CDMathx.block: this.block = v; break;
			case E_CDMathx.critDmg: this.critDmg = v; break;
			case E_CDMathx.hpRegen: this.hpRegen = v; break;
			case E_CDMathx.manaRegen: this.manaRegen = v; break;
			case E_CDMathx.dribbleRegen: this.dribbleRegen = v; break;
			case E_CDMathx.dodgeRegen: this.dodgeRegen = v; break;
			case E_CDMathx.critRegen: this.critRegen = v; break;
			case E_CDMathx.blockRegen: this.blockRegen = v; break;
			case E_CDMathx.phyAtkPercent: this.phyAtkPercent = v; break;
			case E_CDMathx.fireAtkPercent: this.fireAtkPercent = v; break;
			case E_CDMathx.iceAtkPercent: this.iceAtkPercent = v; break;
			case E_CDMathx.lightAtkPercent: this.lightAtkPercent = v; break;
			case E_CDMathx.hpPercent: this.hpPercent = v; break;
			case E_CDMathx.manaPercent: this.manaPercent = v; break;
			case E_CDMathx.hpRegenPercent: this.hpRegenPercent = v; break;
			case E_CDMathx.manaRegenPercent: this.manaRegenPercent = v; break;
			case E_CDMathx.dribbleRegenPercent: this.dribbleRegenPercent = v; break;
			case E_CDMathx.dodgeRegenPercent: this.dodgeRegenPercent = v; break;
			case E_CDMathx.critRegenPercent: this.critRegenPercent = v; break;
			case E_CDMathx.blockRegenPercent: this.blockRegenPercent = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDMathx> = new HashMap<number, CDMathx>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDMathx[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDMathx();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].phyAtk = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].fireAtk = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].iceAtk = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].lightAtk = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].phyDef = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].fireDef = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].iceDef = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].lightDef = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].hp = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].mana = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].normalQuick = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].quick = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].hit = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dribble = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dodge = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].crit = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].res = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].block = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].critDmg = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].hpRegen = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].manaRegen = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dribbleRegen = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dodgeRegen = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].critRegen = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].blockRegen = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].phyAtkPercent = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].fireAtkPercent = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].iceAtkPercent = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].lightAtkPercent = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].hpPercent = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].manaPercent = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].hpRegenPercent = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].manaRegenPercent = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dribbleRegenPercent = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dodgeRegenPercent = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].critRegenPercent = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].blockRegenPercent = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDMathx{
		return this.datas ? this.datas.get(id) : null;
	}
}
